<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\project\controller;

use plugin\saiadmin\basic\BaseController;
use app\project\logic\projectLogic;
use app\project\validate\projectValidate;
use support\Request;
use support\Response;

/**
 * 项目列表控制器
 */
class projectController extends BaseController
{
    /**
     * 数据表主键
     */
    protected $pk = 'project_id';
    
    /**
     * 构造函数
     */
    public function __construct()
    {
        $this->logic = new projectLogic();
        $this->validate = new projectValidate;
        parent::__construct();
    }

    /**
     * 数据列表
     * @param Request $request
     * @return Response
     */
    public function index(Request $request): Response
    {
        $where = $request->more([
            ['project_title', ''],
            ['lang_code','zh'],
        ]);
        $query = $this->logic->search($where)->order('create_time desc');
        $data = $this->logic->getList($query);
        return $this->success($data);
    }
    public function getClass(Request $request): Response
    {
        $where = $request->more([
          
        ]);
        $query = $this->logic->search($where)->field('project_id as value,project_title as label')->order('create_time desc');
        $data = $this->logic->getAll($query);
        return $this->success($data);
    }
}
